package com.tuantuan.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.tuantuan.dao.CommenDao;
import com.tuantuan.model.Courses;
import com.tuantuan.service.CommenService;
@Service("CourseService")
@Transactional
public class CourseServiceImpl implements CommenService<Courses>{

	@Resource(name="CourseDao")
	private CommenDao<Courses> courDao;
	@Override
	public String addEntity(Courses entity) {
		// TODO Auto-generated method stub
		Courses c = this.courDao.queryByCode(entity);
		if(c == null){
			this.courDao.addEntity(entity);
			return "succ";
		}
		return "fail";
	}

	@Override
	public String deleteEntity(int entityId) {
		// TODO Auto-generated method stub
		Courses cc = new Courses();
		cc.setCoId(entityId);
		Courses c = this.courDao.queryById(cc);
		if(c != null){
			this.courDao.deleteEntity(c);
			return "succ";
		}
		return "fail";
	}

	@Override
	public String updateEntity(Courses entity) {
		// TODO Auto-generated method stub
		Courses c = this.courDao.queryByCode(entity);
		if(c == null){
			this.courDao.updateEntity(entity);
			return "succ";
		}
		return "fail";
	}

	
}
